<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>tnef.rtfparser</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="tnef-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="tnef-module.html">Package&nbsp;tnef</a> ::
        Module&nbsp;rtfparser
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="tnef.rtfparser-pysrc.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="tnef.rtfparser-module.html">Module tnef.rtfparser</a></h1>
<pre class="py-src">
<a name="L1"></a><tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L2"></a><tt class="py-lineno">  2</tt>  <tt class="py-line"><tt class="py-docstring">The module implements a pyparsing - based special-purpose RTF parser</tt> </tt>
<a name="L3"></a><tt class="py-lineno">  3</tt>  <tt class="py-line"><tt class="py-docstring">specifically for extracting HTML from RTF contained within a TNEF</tt> </tt>
<a name="L4"></a><tt class="py-lineno">  4</tt>  <tt class="py-line"><tt class="py-docstring">attachment.</tt> </tt>
<a name="L5"></a><tt class="py-lineno">  5</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L6"></a><tt class="py-lineno">  6</tt>  <tt class="py-line"> </tt>
<a name="L7"></a><tt class="py-lineno">  7</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">sys</tt> </tt>
<a name="L8"></a><tt class="py-lineno">  8</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">logging</tt> <tt class="py-keyword">import</tt> <tt class="py-name">critical</tt> </tt>
<a name="L9"></a><tt class="py-lineno">  9</tt>  <tt class="py-line"> </tt>
<a name="L10"></a><tt class="py-lineno"> 10</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">pyparsing</tt> <tt class="py-keyword">import</tt> <tt class="py-name">Optional</tt><tt class="py-op">,</tt> <tt class="py-name">Literal</tt><tt class="py-op">,</tt> <tt class="py-name">Word</tt><tt class="py-op">,</tt> <tt class="py-name">Group</tt> </tt>
<a name="L11"></a><tt class="py-lineno"> 11</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">pyparsing</tt> <tt class="py-keyword">import</tt> <tt class="py-name">Suppress</tt><tt class="py-op">,</tt> <tt class="py-name">Combine</tt><tt class="py-op">,</tt> <tt class="py-name">replaceWith</tt> </tt>
<a name="L12"></a><tt class="py-lineno"> 12</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">pyparsing</tt> <tt class="py-keyword">import</tt> <tt class="py-name">alphas</tt><tt class="py-op">,</tt> <tt class="py-name">nums</tt><tt class="py-op">,</tt> <tt class="py-name">printables</tt><tt class="py-op">,</tt> <tt class="py-name">alphanums</tt> </tt>
<a name="L13"></a><tt class="py-lineno"> 13</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">pyparsing</tt> <tt class="py-keyword">import</tt> <tt class="py-name">restOfLine</tt><tt class="py-op">,</tt> <tt class="py-name">oneOf</tt><tt class="py-op">,</tt> <tt class="py-name">OneOrMore</tt><tt class="py-op">,</tt> <tt class="py-name">ZeroOrMore</tt> </tt>
<a name="L14"></a><tt class="py-lineno"> 14</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">pyparsing</tt> <tt class="py-keyword">import</tt> <tt class="py-name">ParseException</tt> </tt>
<a name="L15"></a><tt class="py-lineno"> 15</tt>  <tt class="py-line"> </tt>
<a name="L16"></a><tt class="py-lineno"> 16</tt>  <tt class="py-line"><tt class="py-name">__all__</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-string">"extract_html_line"</tt><tt class="py-op">,</tt> <tt class="py-string">"extract_html_lines"</tt><tt class="py-op">,</tt> <tt class="py-string">"RTFParserException"</tt><tt class="py-op">,</tt> <tt class="py-string">"parse"</tt><tt class="py-op">,</tt> <tt class="py-string">"write_html_document"</tt><tt class="py-op">)</tt> </tt>
<a name="L17"></a><tt class="py-lineno"> 17</tt>  <tt class="py-line"> </tt>
<a name="RTFParserException"></a><div id="RTFParserException-def"><a name="L18"></a><tt class="py-lineno"> 18</tt> <a class="py-toggle" href="#" id="RTFParserException-toggle" onclick="return toggle('RTFParserException');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="tnef.rtfparser.RTFParserException-class.html">RTFParserException</a><tt class="py-op">(</tt><tt class="py-base-class">Exception</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="RTFParserException-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="RTFParserException-expanded"><a name="L19"></a><tt class="py-lineno"> 19</tt>  <tt class="py-line">   <tt class="py-docstring">"indicate failed RTF parsing"</tt> </tt>
</div><a name="L20"></a><tt class="py-lineno"> 20</tt>  <tt class="py-line"> </tt>
<a name="L21"></a><tt class="py-lineno"> 21</tt>  <tt class="py-line"><tt id="link-0" class="py-name" targets="Variable tnef.rtfparser.htmchars=tnef.rtfparser-module.html#htmchars"><a title="tnef.rtfparser.htmchars" class="py-name" href="#" onclick="return doclink('link-0', 'htmchars', 'link-0');">htmchars</a></tt> <tt class="py-op">=</tt> <tt class="py-name">printables</tt><tt class="py-op">.</tt><tt class="py-name">replace</tt><tt class="py-op">(</tt><tt class="py-string">"&lt;"</tt><tt class="py-op">,</tt><tt class="py-string">""</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">replace</tt><tt class="py-op">(</tt><tt class="py-string">"&gt;"</tt><tt class="py-op">,</tt><tt class="py-string">""</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">replace</tt><tt class="py-op">(</tt><tt class="py-string">"\\"</tt><tt class="py-op">,</tt><tt class="py-string">""</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">replace</tt><tt class="py-op">(</tt><tt class="py-string">"{"</tt><tt class="py-op">,</tt><tt class="py-string">""</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">replace</tt><tt class="py-op">(</tt><tt class="py-string">"}"</tt><tt class="py-op">,</tt><tt class="py-string">""</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-string">" "</tt> <tt class="py-op">+</tt> <tt class="py-string">"\t"</tt> </tt>
<a name="L22"></a><tt class="py-lineno"> 22</tt>  <tt class="py-line"> </tt>
<a name="L23"></a><tt class="py-lineno"> 23</tt>  <tt class="py-line"><tt id="link-1" class="py-name" targets="Variable tnef.rtfparser.SEP=tnef.rtfparser-module.html#SEP"><a title="tnef.rtfparser.SEP" class="py-name" href="#" onclick="return doclink('link-1', 'SEP', 'link-1');">SEP</a></tt> <tt class="py-op">=</tt> <tt class="py-name">Literal</tt><tt class="py-op">(</tt><tt class="py-string">';'</tt><tt class="py-op">)</tt> </tt>
<a name="L24"></a><tt class="py-lineno"> 24</tt>  <tt class="py-line"> </tt>
<a name="L25"></a><tt class="py-lineno"> 25</tt>  <tt class="py-line"><tt id="link-2" class="py-name" targets="Variable tnef.rtfparser.BRCKT_L=tnef.rtfparser-module.html#BRCKT_L"><a title="tnef.rtfparser.BRCKT_L" class="py-name" href="#" onclick="return doclink('link-2', 'BRCKT_L', 'link-2');">BRCKT_L</a></tt> <tt class="py-op">=</tt> <tt class="py-name">Literal</tt><tt class="py-op">(</tt><tt class="py-string">'{'</tt><tt class="py-op">)</tt> </tt>
<a name="L26"></a><tt class="py-lineno"> 26</tt>  <tt class="py-line"><tt id="link-3" class="py-name" targets="Variable tnef.rtfparser.BRCKT_R=tnef.rtfparser-module.html#BRCKT_R"><a title="tnef.rtfparser.BRCKT_R" class="py-name" href="#" onclick="return doclink('link-3', 'BRCKT_R', 'link-3');">BRCKT_R</a></tt> <tt class="py-op">=</tt> <tt class="py-name">Literal</tt><tt class="py-op">(</tt><tt class="py-string">'}'</tt><tt class="py-op">)</tt> </tt>
<a name="L27"></a><tt class="py-lineno"> 27</tt>  <tt class="py-line"><tt id="link-4" class="py-name" targets="Variable tnef.rtfparser.BRCKT=tnef.rtfparser-module.html#BRCKT"><a title="tnef.rtfparser.BRCKT" class="py-name" href="#" onclick="return doclink('link-4', 'BRCKT', 'link-4');">BRCKT</a></tt> <tt class="py-op">=</tt> <tt id="link-5" class="py-name"><a title="tnef.rtfparser.BRCKT_L" class="py-name" href="#" onclick="return doclink('link-5', 'BRCKT_L', 'link-2');">BRCKT_L</a></tt> <tt class="py-op">|</tt> <tt id="link-6" class="py-name"><a title="tnef.rtfparser.BRCKT_R" class="py-name" href="#" onclick="return doclink('link-6', 'BRCKT_R', 'link-3');">BRCKT_R</a></tt> </tt>
<a name="L28"></a><tt class="py-lineno"> 28</tt>  <tt class="py-line"><tt id="link-7" class="py-name"><a title="tnef.rtfparser.BRCKT" class="py-name" href="#" onclick="return doclink('link-7', 'BRCKT', 'link-4');">BRCKT</a></tt><tt class="py-op">.</tt><tt class="py-name">setName</tt><tt class="py-op">(</tt><tt class="py-string">"Bracket"</tt><tt class="py-op">)</tt> </tt>
<a name="L29"></a><tt class="py-lineno"> 29</tt>  <tt class="py-line"> </tt>
<a name="L30"></a><tt class="py-lineno"> 30</tt>  <tt class="py-line"><tt class="py-comment"># basic RTF control codes, ie. "\labelname3434"</tt> </tt>
<a name="L31"></a><tt class="py-lineno"> 31</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt id="link-8" class="py-name" targets="Variable tnef.rtfparser.CTRL_LABEL=tnef.rtfparser-module.html#CTRL_LABEL"><a title="tnef.rtfparser.CTRL_LABEL" class="py-name" href="#" onclick="return doclink('link-8', 'CTRL_LABEL', 'link-8');">CTRL_LABEL</a></tt> <tt class="py-op">=</tt> <tt class="py-name">Combine</tt><tt class="py-op">(</tt><tt class="py-name">Word</tt><tt class="py-op">(</tt><tt class="py-name">alphas</tt> <tt class="py-op">+</tt> <tt class="py-string">"'"</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-name">Optional</tt><tt class="py-op">(</tt><tt class="py-name">Word</tt><tt class="py-op">(</tt><tt class="py-name">nums</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L32"></a><tt class="py-lineno"> 32</tt>  <tt class="py-line"><tt id="link-9" class="py-name" targets="Variable tnef.rtfparser.BASE_CTRL=tnef.rtfparser-module.html#BASE_CTRL"><a title="tnef.rtfparser.BASE_CTRL" class="py-name" href="#" onclick="return doclink('link-9', 'BASE_CTRL', 'link-9');">BASE_CTRL</a></tt> <tt class="py-op">=</tt> <tt class="py-name">Combine</tt><tt class="py-op">(</tt><tt class="py-name">Literal</tt><tt class="py-op">(</tt><tt class="py-string">'\\'</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt id="link-10" class="py-name"><a title="tnef.rtfparser.CTRL_LABEL" class="py-name" href="#" onclick="return doclink('link-10', 'CTRL_LABEL', 'link-8');">CTRL_LABEL</a></tt><tt class="py-op">)</tt> </tt>
<a name="L33"></a><tt class="py-lineno"> 33</tt>  <tt class="py-line"> </tt>
<a name="L34"></a><tt class="py-lineno"> 34</tt>  <tt class="py-line"><tt class="py-comment"># in some rare cases (color table declarations), control has ' ;' suffix</tt> </tt>
<a name="L35"></a><tt class="py-lineno"> 35</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt id="link-11" class="py-name"><a title="tnef.rtfparser.BASE_CTRL" class="py-name" href="#" onclick="return doclink('link-11', 'BASE_CTRL', 'link-9');">BASE_CTRL</a></tt> <tt class="py-op">=</tt> <tt class="py-name">Combine</tt><tt class="py-op">(</tt><tt id="link-12" class="py-name"><a title="tnef.rtfparser.BASE_CTRL" class="py-name" href="#" onclick="return doclink('link-12', 'BASE_CTRL', 'link-9');">BASE_CTRL</a></tt> <tt class="py-op">+</tt> <tt id="link-13" class="py-name"><a title="tnef.rtfparser.SEP" class="py-name" href="#" onclick="return doclink('link-13', 'SEP', 'link-1');">SEP</a></tt><tt class="py-op">)</tt> <tt class="py-op">|</tt> <tt id="link-14" class="py-name"><a title="tnef.rtfparser.BASE_CTRL" class="py-name" href="#" onclick="return doclink('link-14', 'BASE_CTRL', 'link-9');">BASE_CTRL</a></tt> </tt>
<a name="L36"></a><tt class="py-lineno"> 36</tt>  <tt class="py-line"><tt id="link-15" class="py-name"><a title="tnef.rtfparser.BASE_CTRL" class="py-name" href="#" onclick="return doclink('link-15', 'BASE_CTRL', 'link-9');">BASE_CTRL</a></tt><tt class="py-op">.</tt><tt class="py-name">setName</tt><tt class="py-op">(</tt><tt class="py-string">"BaseControl"</tt><tt class="py-op">)</tt> </tt>
<a name="L37"></a><tt class="py-lineno"> 37</tt>  <tt class="py-line"> </tt>
<a name="L38"></a><tt class="py-lineno"> 38</tt>  <tt class="py-line"><tt class="py-comment">#\*\html93394</tt> </tt>
<a name="L39"></a><tt class="py-lineno"> 39</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt id="link-16" class="py-name" targets="Variable tnef.rtfparser.HTM_CTRL=tnef.rtfparser-module.html#HTM_CTRL"><a title="tnef.rtfparser.HTM_CTRL" class="py-name" href="#" onclick="return doclink('link-16', 'HTM_CTRL', 'link-16');">HTM_CTRL</a></tt> <tt class="py-op">=</tt> <tt class="py-name">Combine</tt><tt class="py-op">(</tt><tt class="py-name">Literal</tt><tt class="py-op">(</tt><tt class="py-string">'\\*\\'</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt id="link-17" class="py-name"><a title="tnef.rtfparser.CTRL_LABEL" class="py-name" href="#" onclick="return doclink('link-17', 'CTRL_LABEL', 'link-8');">CTRL_LABEL</a></tt><tt class="py-op">)</tt> </tt>
<a name="L40"></a><tt class="py-lineno"> 40</tt>  <tt class="py-line"><tt id="link-18" class="py-name"><a title="tnef.rtfparser.HTM_CTRL" class="py-name" href="#" onclick="return doclink('link-18', 'HTM_CTRL', 'link-16');">HTM_CTRL</a></tt><tt class="py-op">.</tt><tt class="py-name">setName</tt><tt class="py-op">(</tt><tt class="py-string">"HtmlControl"</tt><tt class="py-op">)</tt> </tt>
<a name="L41"></a><tt class="py-lineno"> 41</tt>  <tt class="py-line"> </tt>
<a name="L42"></a><tt class="py-lineno"> 42</tt>  <tt class="py-line"><tt id="link-19" class="py-name" targets="Variable tnef.rtfparser.RTF_CTRL=tnef.rtfparser-module.html#RTF_CTRL"><a title="tnef.rtfparser.RTF_CTRL" class="py-name" href="#" onclick="return doclink('link-19', 'RTF_CTRL', 'link-19');">RTF_CTRL</a></tt> <tt class="py-op">=</tt> <tt id="link-20" class="py-name"><a title="tnef.rtfparser.BASE_CTRL" class="py-name" href="#" onclick="return doclink('link-20', 'BASE_CTRL', 'link-9');">BASE_CTRL</a></tt> <tt class="py-op">|</tt> <tt id="link-21" class="py-name"><a title="tnef.rtfparser.HTM_CTRL" class="py-name" href="#" onclick="return doclink('link-21', 'HTM_CTRL', 'link-16');">HTM_CTRL</a></tt> </tt>
<a name="L43"></a><tt class="py-lineno"> 43</tt>  <tt class="py-line"><tt id="link-22" class="py-name"><a title="tnef.rtfparser.RTF_CTRL" class="py-name" href="#" onclick="return doclink('link-22', 'RTF_CTRL', 'link-19');">RTF_CTRL</a></tt><tt class="py-op">.</tt><tt class="py-name">setName</tt><tt class="py-op">(</tt><tt class="py-string">"Control"</tt><tt class="py-op">)</tt> </tt>
<a name="L44"></a><tt class="py-lineno"> 44</tt>  <tt class="py-line"> </tt>
<a name="L45"></a><tt class="py-lineno"> 45</tt>  <tt class="py-line"><tt id="link-23" class="py-name" targets="Variable tnef.rtfparser.RTFCODE=tnef.rtfparser-module.html#RTFCODE"><a title="tnef.rtfparser.RTFCODE" class="py-name" href="#" onclick="return doclink('link-23', 'RTFCODE', 'link-23');">RTFCODE</a></tt> <tt class="py-op">=</tt> <tt class="py-name">OneOrMore</tt><tt class="py-op">(</tt><tt id="link-24" class="py-name"><a title="tnef.rtfparser.RTF_CTRL" class="py-name" href="#" onclick="return doclink('link-24', 'RTF_CTRL', 'link-19');">RTF_CTRL</a></tt> <tt class="py-op">|</tt> <tt id="link-25" class="py-name"><a title="tnef.rtfparser.BRCKT" class="py-name" href="#" onclick="return doclink('link-25', 'BRCKT', 'link-4');">BRCKT</a></tt><tt class="py-op">)</tt> </tt>
<a name="L46"></a><tt class="py-lineno"> 46</tt>  <tt class="py-line"> </tt>
<a name="L47"></a><tt class="py-lineno"> 47</tt>  <tt class="py-line"><tt class="py-comment"># handle "{\*\htmltag4 \par }""</tt> </tt>
<a name="L48"></a><tt class="py-lineno"> 48</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt id="link-26" class="py-name" targets="Variable tnef.rtfparser.HTM_CTRL_NEWLINE=tnef.rtfparser-module.html#HTM_CTRL_NEWLINE"><a title="tnef.rtfparser.HTM_CTRL_NEWLINE" class="py-name" href="#" onclick="return doclink('link-26', 'HTM_CTRL_NEWLINE', 'link-26');">HTM_CTRL_NEWLINE</a></tt> <tt class="py-op">=</tt> <tt id="link-27" class="py-name"><a title="tnef.rtfparser.HTM_CTRL" class="py-name" href="#" onclick="return doclink('link-27', 'HTM_CTRL', 'link-16');">HTM_CTRL</a></tt><tt class="py-op">.</tt><tt class="py-name">suppress</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-name">Literal</tt><tt class="py-op">(</tt><tt class="py-string">"\\par"</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">setParseAction</tt><tt class="py-op">(</tt><tt class="py-name">replaceWith</tt><tt class="py-op">(</tt><tt class="py-string">"\n"</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L49"></a><tt class="py-lineno"> 49</tt>  <tt class="py-line"><tt id="link-28" class="py-name"><a title="tnef.rtfparser.HTM_CTRL_NEWLINE" class="py-name" href="#" onclick="return doclink('link-28', 'HTM_CTRL_NEWLINE', 'link-26');">HTM_CTRL_NEWLINE</a></tt><tt class="py-op">.</tt><tt class="py-name">suppress</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L50"></a><tt class="py-lineno"> 50</tt>  <tt class="py-line"> </tt>
<a name="L51"></a><tt class="py-lineno"> 51</tt>  <tt class="py-line"><tt class="py-comment"># handle "{\*\htmltag84       }"</tt> </tt>
<a name="L52"></a><tt class="py-lineno"> 52</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt id="link-29" class="py-name" targets="Variable tnef.rtfparser.HTM_CTRL_EMPTY=tnef.rtfparser-module.html#HTM_CTRL_EMPTY"><a title="tnef.rtfparser.HTM_CTRL_EMPTY" class="py-name" href="#" onclick="return doclink('link-29', 'HTM_CTRL_EMPTY', 'link-29');">HTM_CTRL_EMPTY</a></tt> <tt class="py-op">=</tt> <tt id="link-30" class="py-name"><a title="tnef.rtfparser.HTM_CTRL" class="py-name" href="#" onclick="return doclink('link-30', 'HTM_CTRL', 'link-16');">HTM_CTRL</a></tt><tt class="py-op">.</tt><tt class="py-name">suppress</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-name">Word</tt><tt class="py-op">(</tt><tt class="py-string">" "</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">leaveWhitespace</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L53"></a><tt class="py-lineno"> 53</tt>  <tt class="py-line"> </tt>
<a name="L54"></a><tt class="py-lineno"> 54</tt>  <tt class="py-line"><tt id="link-31" class="py-name" targets="Variable tnef.rtfparser.HTM_TXT=tnef.rtfparser-module.html#HTM_TXT"><a title="tnef.rtfparser.HTM_TXT" class="py-name" href="#" onclick="return doclink('link-31', 'HTM_TXT', 'link-31');">HTM_TXT</a></tt> <tt class="py-op">=</tt>  <tt class="py-name">OneOrMore</tt><tt class="py-op">(</tt><tt class="py-name">Word</tt><tt class="py-op">(</tt><tt id="link-32" class="py-name"><a title="tnef.rtfparser.htmchars" class="py-name" href="#" onclick="return doclink('link-32', 'htmchars', 'link-0');">htmchars</a></tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L55"></a><tt class="py-lineno"> 55</tt>  <tt class="py-line"><tt id="link-33" class="py-name" targets="Variable tnef.rtfparser.HTM_CTRL_CONTENT=tnef.rtfparser-module.html#HTM_CTRL_CONTENT"><a title="tnef.rtfparser.HTM_CTRL_CONTENT" class="py-name" href="#" onclick="return doclink('link-33', 'HTM_CTRL_CONTENT', 'link-33');">HTM_CTRL_CONTENT</a></tt> <tt class="py-op">=</tt> <tt id="link-34" class="py-name"><a title="tnef.rtfparser.HTM_CTRL" class="py-name" href="#" onclick="return doclink('link-34', 'HTM_CTRL', 'link-16');">HTM_CTRL</a></tt><tt class="py-op">.</tt><tt class="py-name">suppress</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-name">Optional</tt><tt class="py-op">(</tt><tt id="link-35" class="py-name"><a title="tnef.rtfparser.BRCKT_R" class="py-name" href="#" onclick="return doclink('link-35', 'BRCKT_R', 'link-3');">BRCKT_R</a></tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">suppress</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt id="link-36" class="py-name"><a title="tnef.rtfparser.HTM_TXT" class="py-name" href="#" onclick="return doclink('link-36', 'HTM_TXT', 'link-31');">HTM_TXT</a></tt> </tt>
<a name="L56"></a><tt class="py-lineno"> 56</tt>  <tt class="py-line"> </tt>
<a name="L57"></a><tt class="py-lineno"> 57</tt>  <tt class="py-line"><tt class="py-comment"># Both opening and closing tags and their contents</tt> </tt>
<a name="L58"></a><tt class="py-lineno"> 58</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt id="link-37" class="py-name" targets="Variable tnef.rtfparser.HTM_TAG=tnef.rtfparser-module.html#HTM_TAG"><a title="tnef.rtfparser.HTM_TAG" class="py-name" href="#" onclick="return doclink('link-37', 'HTM_TAG', 'link-37');">HTM_TAG</a></tt> <tt class="py-op">=</tt> <tt class="py-name">Combine</tt><tt class="py-op">(</tt><tt class="py-name">Literal</tt><tt class="py-op">(</tt><tt class="py-string">"&lt;"</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-name">Word</tt><tt class="py-op">(</tt><tt id="link-38" class="py-name"><a title="tnef.rtfparser.htmchars" class="py-name" href="#" onclick="return doclink('link-38', 'htmchars', 'link-0');">htmchars</a></tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-name">Literal</tt><tt class="py-op">(</tt><tt class="py-string">"&gt;"</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L59"></a><tt class="py-lineno"> 59</tt>  <tt class="py-line"><tt id="link-39" class="py-name"><a title="tnef.rtfparser.HTM_TAG" class="py-name" href="#" onclick="return doclink('link-39', 'HTM_TAG', 'link-37');">HTM_TAG</a></tt><tt class="py-op">.</tt><tt class="py-name">leaveWhitespace</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L60"></a><tt class="py-lineno"> 60</tt>  <tt class="py-line"><tt id="link-40" class="py-name"><a title="tnef.rtfparser.HTM_TAG" class="py-name" href="#" onclick="return doclink('link-40', 'HTM_TAG', 'link-37');">HTM_TAG</a></tt><tt class="py-op">.</tt><tt class="py-name">setName</tt><tt class="py-op">(</tt><tt class="py-string">"HtmlTag"</tt><tt class="py-op">)</tt> </tt>
<a name="L61"></a><tt class="py-lineno"> 61</tt>  <tt class="py-line">      </tt>
<a name="L62"></a><tt class="py-lineno"> 62</tt>  <tt class="py-line"><tt class="py-comment">#HTM_TAG_EMPTYCONTENT = Word(" ") + BRCKT_R.suppress()</tt> </tt>
<a name="L63"></a><tt class="py-lineno"> 63</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt id="link-41" class="py-name" targets="Variable tnef.rtfparser.HTM_TAG_PLUS_CONTENT=tnef.rtfparser-module.html#HTM_TAG_PLUS_CONTENT"><a title="tnef.rtfparser.HTM_TAG_PLUS_CONTENT" class="py-name" href="#" onclick="return doclink('link-41', 'HTM_TAG_PLUS_CONTENT', 'link-41');">HTM_TAG_PLUS_CONTENT</a></tt> <tt class="py-op">=</tt> <tt id="link-42" class="py-name"><a title="tnef.rtfparser.HTM_TAG" class="py-name" href="#" onclick="return doclink('link-42', 'HTM_TAG', 'link-37');">HTM_TAG</a></tt> <tt class="py-op">+</tt> <tt class="py-name">Optional</tt><tt class="py-op">(</tt><tt id="link-43" class="py-name"><a title="tnef.rtfparser.BRCKT_R" class="py-name" href="#" onclick="return doclink('link-43', 'BRCKT_R', 'link-3');">BRCKT_R</a></tt><tt class="py-op">.</tt><tt class="py-name">suppress</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt id="link-44" class="py-name"><a title="tnef.rtfparser.HTM_TXT" class="py-name" href="#" onclick="return doclink('link-44', 'HTM_TXT', 'link-31');">HTM_TXT</a></tt><tt class="py-op">)</tt> </tt>
<a name="L64"></a><tt class="py-lineno"> 64</tt>  <tt class="py-line"><tt id="link-45" class="py-name"><a title="tnef.rtfparser.HTM_TAG_PLUS_CONTENT" class="py-name" href="#" onclick="return doclink('link-45', 'HTM_TAG_PLUS_CONTENT', 'link-41');">HTM_TAG_PLUS_CONTENT</a></tt><tt class="py-op">.</tt><tt class="py-name">leaveWhitespace</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L65"></a><tt class="py-lineno"> 65</tt>  <tt class="py-line"> </tt>
<a name="L66"></a><tt class="py-lineno"> 66</tt>  <tt class="py-line"><tt class="py-comment"># Text content inside HTML</tt> </tt>
<a name="L67"></a><tt class="py-lineno"> 67</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt id="link-46" class="py-name" targets="Variable tnef.rtfparser.HTM_CONTENT_IND=tnef.rtfparser-module.html#HTM_CONTENT_IND"><a title="tnef.rtfparser.HTM_CONTENT_IND" class="py-name" href="#" onclick="return doclink('link-46', 'HTM_CONTENT_IND', 'link-46');">HTM_CONTENT_IND</a></tt> <tt class="py-op">=</tt> <tt class="py-name">Suppress</tt><tt class="py-op">(</tt><tt class="py-string">"\\htmlrtf0 "</tt><tt class="py-op">)</tt> </tt>
<a name="L68"></a><tt class="py-lineno"> 68</tt>  <tt class="py-line"><tt id="link-47" class="py-name" targets="Variable tnef.rtfparser.HTM_CONTENT=tnef.rtfparser-module.html#HTM_CONTENT"><a title="tnef.rtfparser.HTM_CONTENT" class="py-name" href="#" onclick="return doclink('link-47', 'HTM_CONTENT', 'link-47');">HTM_CONTENT</a></tt> <tt class="py-op">=</tt> <tt id="link-48" class="py-name"><a title="tnef.rtfparser.HTM_CONTENT_IND" class="py-name" href="#" onclick="return doclink('link-48', 'HTM_CONTENT_IND', 'link-46');">HTM_CONTENT_IND</a></tt> <tt class="py-op">+</tt> <tt class="py-name">OneOrMore</tt><tt class="py-op">(</tt><tt class="py-name">Word</tt><tt class="py-op">(</tt><tt id="link-49" class="py-name"><a title="tnef.rtfparser.htmchars" class="py-name" href="#" onclick="return doclink('link-49', 'htmchars', 'link-0');">htmchars</a></tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L69"></a><tt class="py-lineno"> 69</tt>  <tt class="py-line"> </tt>
<a name="L70"></a><tt class="py-lineno"> 70</tt>  <tt class="py-line"><tt id="link-50" class="py-name"><a title="tnef.rtfparser.HTM_CONTENT" class="py-name" href="#" onclick="return doclink('link-50', 'HTM_CONTENT', 'link-47');">HTM_CONTENT</a></tt><tt class="py-op">.</tt><tt class="py-name">setName</tt><tt class="py-op">(</tt><tt class="py-string">"Html content"</tt><tt class="py-op">)</tt> </tt>
<a name="L71"></a><tt class="py-lineno"> 71</tt>  <tt class="py-line"><tt id="link-51" class="py-name"><a title="tnef.rtfparser.HTM_CONTENT" class="py-name" href="#" onclick="return doclink('link-51', 'HTM_CONTENT', 'link-47');">HTM_CONTENT</a></tt><tt class="py-op">.</tt><tt class="py-name">leaveWhitespace</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L72"></a><tt class="py-lineno"> 72</tt>  <tt class="py-line"> </tt>
<a name="L73"></a><tt class="py-lineno"> 73</tt>  <tt class="py-line"><tt id="link-52" class="py-name" targets="Variable tnef.rtfparser.RTFLINK=tnef.rtfparser-module.html#RTFLINK"><a title="tnef.rtfparser.RTFLINK" class="py-name" href="#" onclick="return doclink('link-52', 'RTFLINK', 'link-52');">RTFLINK</a></tt> <tt class="py-op">=</tt> <tt class="py-name">Suppress</tt><tt class="py-op">(</tt><tt class="py-string">"HYPERLINK \""</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-name">Word</tt><tt class="py-op">(</tt><tt id="link-53" class="py-name"><a title="tnef.rtfparser.htmchars" class="py-name" href="#" onclick="return doclink('link-53', 'htmchars', 'link-0');">htmchars</a></tt><tt class="py-op">.</tt><tt class="py-name">replace</tt><tt class="py-op">(</tt><tt class="py-string">'"'</tt><tt class="py-op">,</tt><tt class="py-string">''</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-name">Literal</tt><tt class="py-op">(</tt><tt class="py-string">'"'</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">suppress</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L74"></a><tt class="py-lineno"> 74</tt>  <tt class="py-line"> </tt>
<a name="L75"></a><tt class="py-lineno"> 75</tt>  <tt class="py-line"><tt id="link-54" class="py-name" targets="Variable tnef.rtfparser.RTF=tnef.rtfparser-module.html#RTF"><a title="tnef.rtfparser.RTF" class="py-name" href="#" onclick="return doclink('link-54', 'RTF', 'link-54');">RTF</a></tt> <tt class="py-op">=</tt> <tt class="py-name">OneOrMore</tt><tt class="py-op">(</tt> </tt>
<a name="L76"></a><tt class="py-lineno"> 76</tt>  <tt class="py-line">   <tt id="link-55" class="py-name"><a title="tnef.rtfparser.HTM_CTRL_CONTENT" class="py-name" href="#" onclick="return doclink('link-55', 'HTM_CTRL_CONTENT', 'link-33');">HTM_CTRL_CONTENT</a></tt> <tt class="py-op">|</tt> \ </tt>
<a name="L77"></a><tt class="py-lineno"> 77</tt>  <tt class="py-line">   <tt id="link-56" class="py-name"><a title="tnef.rtfparser.HTM_TAG_PLUS_CONTENT" class="py-name" href="#" onclick="return doclink('link-56', 'HTM_TAG_PLUS_CONTENT', 'link-41');">HTM_TAG_PLUS_CONTENT</a></tt> <tt class="py-op">|</tt> \ </tt>
<a name="L78"></a><tt class="py-lineno"> 78</tt>  <tt class="py-line">   <tt id="link-57" class="py-name"><a title="tnef.rtfparser.HTM_CONTENT" class="py-name" href="#" onclick="return doclink('link-57', 'HTM_CONTENT', 'link-47');">HTM_CONTENT</a></tt> <tt class="py-op">|</tt>  \ </tt>
<a name="L79"></a><tt class="py-lineno"> 79</tt>  <tt class="py-line">   <tt id="link-58" class="py-name"><a title="tnef.rtfparser.HTM_CTRL_NEWLINE" class="py-name" href="#" onclick="return doclink('link-58', 'HTM_CTRL_NEWLINE', 'link-26');">HTM_CTRL_NEWLINE</a></tt> <tt class="py-op">|</tt> \ </tt>
<a name="L80"></a><tt class="py-lineno"> 80</tt>  <tt class="py-line">   <tt class="py-comment">#HTM_CTRL_EMPTY | \</tt> </tt>
<a name="L81"></a><tt class="py-lineno"> 81</tt>  <tt class="py-line">   <tt id="link-59" class="py-name"><a title="tnef.rtfparser.RTFLINK" class="py-name" href="#" onclick="return doclink('link-59', 'RTFLINK', 'link-52');">RTFLINK</a></tt><tt class="py-op">.</tt><tt class="py-name">suppress</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-op">|</tt> \ </tt>
<a name="L82"></a><tt class="py-lineno"> 82</tt>  <tt class="py-line">   <tt id="link-60" class="py-name"><a title="tnef.rtfparser.RTF_CTRL" class="py-name" href="#" onclick="return doclink('link-60', 'RTF_CTRL', 'link-19');">RTF_CTRL</a></tt><tt class="py-op">.</tt><tt class="py-name">suppress</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-op">|</tt> \ </tt>
<a name="L83"></a><tt class="py-lineno"> 83</tt>  <tt class="py-line">   <tt id="link-61" class="py-name"><a title="tnef.rtfparser.BRCKT" class="py-name" href="#" onclick="return doclink('link-61', 'BRCKT', 'link-4');">BRCKT</a></tt><tt class="py-op">.</tt><tt class="py-name">suppress</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L84"></a><tt class="py-lineno"> 84</tt>  <tt class="py-line"><tt class="py-op">)</tt>   </tt>
<a name="L85"></a><tt class="py-lineno"> 85</tt>  <tt class="py-line"> </tt>
<a name="L86"></a><tt class="py-lineno"> 86</tt>  <tt class="py-line"> </tt>
<a name="parse"></a><div id="parse-def"><a name="L87"></a><tt class="py-lineno"> 87</tt> <a class="py-toggle" href="#" id="parse-toggle" onclick="return toggle('parse');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="tnef.rtfparser-module.html#parse">parse</a><tt class="py-op">(</tt><tt class="py-param">rtfstring</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="parse-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="parse-expanded"><a name="L88"></a><tt class="py-lineno"> 88</tt>  <tt class="py-line">   <tt class="py-docstring">"return parse result as string"</tt> </tt>
<a name="L89"></a><tt class="py-lineno"> 89</tt>  <tt class="py-line">   <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<a name="L90"></a><tt class="py-lineno"> 90</tt>  <tt class="py-line">      <tt class="py-name">result</tt> <tt class="py-op">=</tt> <tt id="link-62" class="py-name"><a title="tnef.rtfparser.RTF" class="py-name" href="#" onclick="return doclink('link-62', 'RTF', 'link-54');">RTF</a></tt><tt class="py-op">.</tt><tt class="py-name">parseString</tt><tt class="py-op">(</tt><tt class="py-name">rtfstring</tt><tt class="py-op">)</tt> </tt>
<a name="L91"></a><tt class="py-lineno"> 91</tt>  <tt class="py-line">   <tt class="py-keyword">except</tt> <tt class="py-name">ParseException</tt><tt class="py-op">,</tt> <tt class="py-name">e</tt><tt class="py-op">:</tt> </tt>
<a name="L92"></a><tt class="py-lineno"> 92</tt>  <tt class="py-line">      <tt class="py-keyword">raise</tt> <tt id="link-63" class="py-name" targets="Class tnef.rtfparser.RTFParserException=tnef.rtfparser.RTFParserException-class.html"><a title="tnef.rtfparser.RTFParserException" class="py-name" href="#" onclick="return doclink('link-63', 'RTFParserException', 'link-63');">RTFParserException</a></tt><tt class="py-op">(</tt><tt class="py-string">"could not parse '%s'... : %s"</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">rtfstring</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-number">30</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-name">e</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L93"></a><tt class="py-lineno"> 93</tt>  <tt class="py-line">   <tt class="py-keyword">return</tt> <tt class="py-string">""</tt><tt class="py-op">.</tt><tt class="py-name">join</tt><tt class="py-op">(</tt><tt class="py-name">result</tt><tt class="py-op">)</tt> </tt>
</div><a name="L94"></a><tt class="py-lineno"> 94</tt>  <tt class="py-line">       </tt>
<a name="L95"></a><tt class="py-lineno"> 95</tt>  <tt class="py-line">    </tt>
<a name="extract_html_line"></a><div id="extract_html_line-def"><a name="L96"></a><tt class="py-lineno"> 96</tt> <a class="py-toggle" href="#" id="extract_html_line-toggle" onclick="return toggle('extract_html_line');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="tnef.rtfparser-module.html#extract_html_line">extract_html_line</a><tt class="py-op">(</tt><tt class="py-param">rtfline</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="extract_html_line-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="extract_html_line-expanded"><a name="L97"></a><tt class="py-lineno"> 97</tt>  <tt class="py-line">   <tt class="py-docstring">"extract a single line of HTML embedded in RTF"</tt> </tt>
<a name="L98"></a><tt class="py-lineno"> 98</tt>  <tt class="py-line">   <tt class="py-keyword">return</tt> <tt class="py-name">rtfline</tt> <tt class="py-keyword">if</tt> <tt class="py-name">rtfline</tt><tt class="py-op">.</tt><tt class="py-name">isspace</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-keyword">else</tt> <tt id="link-64" class="py-name" targets="Function tnef.rtfparser.parse()=tnef.rtfparser-module.html#parse"><a title="tnef.rtfparser.parse" class="py-name" href="#" onclick="return doclink('link-64', 'parse', 'link-64');">parse</a></tt><tt class="py-op">(</tt><tt class="py-name">rtfline</tt><tt class="py-op">)</tt> </tt>
</div><a name="L99"></a><tt class="py-lineno"> 99</tt>  <tt class="py-line">    </tt>
<a name="L100"></a><tt class="py-lineno">100</tt>  <tt class="py-line">    </tt>
<a name="extract_html_lines"></a><div id="extract_html_lines-def"><a name="L101"></a><tt class="py-lineno">101</tt> <a class="py-toggle" href="#" id="extract_html_lines-toggle" onclick="return toggle('extract_html_lines');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="tnef.rtfparser-module.html#extract_html_lines">extract_html_lines</a><tt class="py-op">(</tt><tt class="py-param">rtffile</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="extract_html_lines-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="extract_html_lines-expanded"><a name="L102"></a><tt class="py-lineno">102</tt>  <tt class="py-line">   <tt class="py-docstring">"extract a full HTML document embedded in RTF"</tt> </tt>
<a name="L103"></a><tt class="py-lineno">103</tt>  <tt class="py-line"> </tt>
<a name="L104"></a><tt class="py-lineno">104</tt>  <tt class="py-line">   <tt class="py-keyword">for</tt> <tt class="py-name">i</tt><tt class="py-op">,</tt> <tt class="py-name">l</tt> <tt class="py-keyword">in</tt> <tt class="py-name">enumerate</tt><tt class="py-op">(</tt><tt class="py-name">rtffile</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L105"></a><tt class="py-lineno">105</tt>  <tt class="py-line">      <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<a name="L106"></a><tt class="py-lineno">106</tt>  <tt class="py-line">         <tt class="py-keyword">if</tt> <tt class="py-name">l</tt><tt class="py-op">:</tt> </tt>
<a name="L107"></a><tt class="py-lineno">107</tt>  <tt class="py-line">            <tt class="py-name">result</tt> <tt class="py-op">=</tt> <tt id="link-65" class="py-name" targets="Function tnef.rtfparser.extract_html_line()=tnef.rtfparser-module.html#extract_html_line"><a title="tnef.rtfparser.extract_html_line" class="py-name" href="#" onclick="return doclink('link-65', 'extract_html_line', 'link-65');">extract_html_line</a></tt><tt class="py-op">(</tt><tt class="py-name">l</tt><tt class="py-op">)</tt> </tt>
<a name="L108"></a><tt class="py-lineno">108</tt>  <tt class="py-line">      <tt class="py-keyword">except</tt> <tt id="link-66" class="py-name"><a title="tnef.rtfparser.RTFParserException" class="py-name" href="#" onclick="return doclink('link-66', 'RTFParserException', 'link-63');">RTFParserException</a></tt><tt class="py-op">,</tt> <tt class="py-name">e</tt><tt class="py-op">:</tt> </tt>
<a name="L109"></a><tt class="py-lineno">109</tt>  <tt class="py-line">         <tt class="py-keyword">raise</tt> <tt id="link-67" class="py-name"><a title="tnef.rtfparser.RTFParserException" class="py-name" href="#" onclick="return doclink('link-67', 'RTFParserException', 'link-63');">RTFParserException</a></tt><tt class="py-op">(</tt><tt class="py-string">"line %i: %s"</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">i</tt><tt class="py-op">,</tt> <tt class="py-name">e</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L110"></a><tt class="py-lineno">110</tt>  <tt class="py-line">          </tt>
<a name="L111"></a><tt class="py-lineno">111</tt>  <tt class="py-line">      <tt class="py-keyword">if</tt> <tt class="py-name">result</tt><tt class="py-op">:</tt> </tt>
<a name="L112"></a><tt class="py-lineno">112</tt>  <tt class="py-line">         <tt class="py-keyword">yield</tt> <tt class="py-name">result</tt> </tt>
</div><a name="L113"></a><tt class="py-lineno">113</tt>  <tt class="py-line"> </tt>
<a name="L114"></a><tt class="py-lineno">114</tt>  <tt class="py-line">    </tt>
<a name="write_html_document"></a><div id="write_html_document-def"><a name="L115"></a><tt class="py-lineno">115</tt> <a class="py-toggle" href="#" id="write_html_document-toggle" onclick="return toggle('write_html_document');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="tnef.rtfparser-module.html#write_html_document">write_html_document</a><tt class="py-op">(</tt><tt class="py-param">sourcefilename</tt><tt class="py-op">,</tt> <tt class="py-param">htmlfilename</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="write_html_document-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="write_html_document-expanded"><a name="L116"></a><tt class="py-lineno">116</tt>  <tt class="py-line">   <tt class="py-docstring">"convenience for writing html out from rtf"</tt> </tt>
<a name="L117"></a><tt class="py-lineno">117</tt>  <tt class="py-line">   <tt class="py-name">src</tt> <tt class="py-op">=</tt> <tt class="py-name">open</tt><tt class="py-op">(</tt><tt class="py-name">sourcefilename</tt><tt class="py-op">)</tt> </tt>
<a name="L118"></a><tt class="py-lineno">118</tt>  <tt class="py-line">   <tt class="py-name">htmlfile</tt> <tt class="py-op">=</tt> <tt class="py-name">open</tt><tt class="py-op">(</tt><tt class="py-name">htmlfilename</tt><tt class="py-op">,</tt> <tt class="py-string">"w"</tt><tt class="py-op">)</tt> </tt>
<a name="L119"></a><tt class="py-lineno">119</tt>  <tt class="py-line">   <tt class="py-keyword">for</tt> <tt class="py-name">l</tt> <tt class="py-keyword">in</tt> <tt id="link-68" class="py-name" targets="Function tnef.rtfparser.extract_html_lines()=tnef.rtfparser-module.html#extract_html_lines"><a title="tnef.rtfparser.extract_html_lines" class="py-name" href="#" onclick="return doclink('link-68', 'extract_html_lines', 'link-68');">extract_html_lines</a></tt><tt class="py-op">(</tt><tt class="py-name">src</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L120"></a><tt class="py-lineno">120</tt>  <tt class="py-line">      <tt class="py-name">htmlfile</tt><tt class="py-op">.</tt><tt class="py-name">write</tt><tt class="py-op">(</tt><tt class="py-name">l</tt><tt class="py-op">)</tt> </tt>
<a name="L121"></a><tt class="py-lineno">121</tt>  <tt class="py-line">   <tt class="py-name">src</tt><tt class="py-op">.</tt><tt class="py-name">close</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L122"></a><tt class="py-lineno">122</tt>  <tt class="py-line">   <tt class="py-name">htmlfile</tt><tt class="py-op">.</tt><tt class="py-name">close</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L123"></a><tt class="py-lineno">123</tt>  <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="tnef-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Fri May 23 20:36:21 2008
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
